package ${basePackage}.cli.command;

import cn.hutool.core.bean.BeanUtil;
import lombok.Data;
import ${basePackage}.generator.MainGenerator;
import ${basePackage}.model.DataModel;
import picocli.CommandLine;

import java.util.concurrent.Callable;

/**
 * 生成代码命令
 * @author ${author}
 */
@Data
@CommandLine.Command(name = "generate", description = "生成代码", mixinStandardHelpOptions = true)
public class GeneratorCommand implements Callable<Integer> {

    <#list modelConfig.models as ModelInfo>
        <#if ModelInfo.description??>
        /**
        * ${ModelInfo.description}
        */
        </#if>
        @CommandLine.Option(names = {"-${ModelInfo.abbr}", "--${ModelInfo.fieldName}"}, interactive = true, arity = "0..1", description = "${ModelInfo.description}", echo = true)
        private ${ModelInfo.type} ${ModelInfo.fieldName};
    </#list>

    @Override
    public Integer call() throws Exception {
        DataModel config = new DataModel();
        BeanUtil.copyProperties(this, config);
        // 进行代码生成
        MainGenerator.doGenerate(config);
        return 0;
    }
}